package com.js.rest.bot;

import cn.dev33.satoken.stp.StpUtil;
import com.js.domian.entity.bot.ResponseEntity;
import com.js.domian.model.AjaxResult;
import com.js.domian.vo.bot.ResponseVo;
import com.js.service.bot.basics.ResponseService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/bot/response")
@RestController
@RequiredArgsConstructor
public class ResponseRest {
    private final ResponseService responseService;

    @PostMapping("/getResponseList")
    public AjaxResult getResponseList(@RequestBody ResponseVo vo){
        vo.setCreateBy(StpUtil.getLoginIdAsString());
        return AjaxResult.ok(responseService.getResponseList(vo));
    }

    @PostMapping("/addResponse")
    public AjaxResult addResponse(@RequestBody ResponseEntity entity){
        responseService.addResponse(entity);
        return AjaxResult.ok();
    }

    @GetMapping("/deleteResponse")
    public AjaxResult deleteResponse(@RequestParam("id") Integer id){
        responseService.deleteResponse(id);
        return AjaxResult.ok();
    }

    @GetMapping("/getAllResponseClass")
    public AjaxResult getAllResponseClass(){
        return AjaxResult.ok(responseService.getAllResponseClass());
    }
}
